﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Core.Repository;
using User.Model;
using Core.UnitOfWork;

namespace User.Repository
{
    public class ResourceRepository : Repository<Resource>, IResourceRepository
    {
        public ResourceRepository(IUnitOfWork unitOfWork)
            : base(unitOfWork)
        {
        }

        public Resource GetRoot()
        {
            Resource root = this.Find(c => c.Level == 1).SingleOrDefault();
            if (root == null)
                throw new Exception("没有找到根节点，请检查数据！");
            return root;
        }
    }
}
